package model

import "gorm.io/gorm"

type Course struct {
	gorm.Model
	CourseName   string `gorm:"type:varchar(30)" json:"courseName"`
	Image        string `gorm:"type:varchar(255)" json:"image"`
	Refer        string `gorm:"type:varchar(100)" json:"refer"`
	CourseStatus int    `gorm:"type:int" json:"courseStatus"`
}

func (c *Course) GetCourse(db *gorm.DB, courseName string) error {
	err := db.Where("course_name = ?", courseName).First(&c).Error
	return err
}

func (c *Course) Upload(db *gorm.DB) error {
	err := db.Updates(&c).Error
	return err
}
func (c *Course) DelCourse(db *gorm.DB, id int) error {
	err := db.Delete(&c, id).Error
	return err
}
